<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>展示</title>
    <link rel="stylesheet" href="/static/css/layui.css"  media="all">
</head>
<body>
<div class="layui-form">
    <table class="layui-table">
        <colgroup>
            <col width="150">
            <col width="150">
            <col width="200">
            <col>
        </colgroup>
        <thead>
        <tr class="layui-bg-blue">
            <th>ID</th>
            <th>标题</th>
            <th>发表时间</th>
            <th>图片</th>
            <th>描述</th>
            <th>显示</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $data as $k=>$v}
           <tr>
               <td>{$v.id}</td>
               <td>{$v.title}</td>
               <td>{$v.create_time|date='Y-m-d H:i:s'}</td>

               <td>
                   {foreach $v.imgs as $value}
                   <img src="{$value}" width="80px">
                   {/foreach}
               </td>

<!--               富文本原样输出-->
               <td>{$v.desc|raw}</td>
               <td ><button class="xian" nameone="{$v.status}" nametwo="{$v.id}">{$v.status==0?'显示':'不显示'}</button></td>
               <td>
                   <a href="#" class="layui-bg-green">查看</a>
                   <button class="layui-bg-red del " id="{$v.id}">删除{$v.id}</button>
               </td>
           </tr>
        {/foreach}
        </tbody>
    </table>
</div>
</body>
<script src="/static/js/jquery-3.1.1.min.js"></script>
<script>
    $(function () {
       $('.del').click(function () {
              var id=$(this).attr('id');
               // console.log(id);
               $.post(
                   'delete',
                   {id:id},
                   function(data){
                       console.log(data);
                   }
               )
       })
        $('.xian').click(function () {
            var one=$(this).attr('nameone');
            var id=$(this).attr('nametwo');
                  console.log(id);
                  $.post(
                      'update',
                      {
                          one:one,
                          id:id
                      },
                      function (data) {
                          location=location;
                      }
                  )
        })
    })
</script>
</html>